Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
cli-columns
Advanced tools
The cli-columns npm package is a utility for formatting text into columns for command-line interfaces. It helps in organizing and displaying data in a tabular format, making it easier to read and understand.
Basic Column Formatting
This feature allows you to format an array of strings into columns. The code sample demonstrates how to use the cli-columns package to display a list of items in a columnar format.
const columns = require('cli-columns');
const data = ['Name', 'Age', 'Occupation', 'Location'];
console.log(columns(data));
Custom Column Width
This feature allows you to specify a custom width for the columns. The code sample shows how to set the column width to 20 characters.
const columns = require('cli-columns');
const data = ['Name', 'Age', 'Occupation', 'Location'];
console.log(columns(data, { width: 20 }));
Column Padding
This feature allows you to add padding between columns. The code sample demonstrates how to add 2 spaces of padding between each column.
const columns = require('cli-columns');
const data = ['Name', 'Age', 'Occupation', 'Location'];
console.log(columns(data, { padding: 2 }));
The columnify package is another utility for formatting text into columns. It offers more customization options such as column alignment, data transformation, and custom column headers. Compared to cli-columns, columnify provides more advanced features for complex data formatting.
The cli-table package is a popular choice for creating tables in the command line. It supports features like text wrapping, custom table styles, and nested tables. While cli-columns focuses on simple column formatting, cli-table offers a more comprehensive solution for creating detailed tables.
The easy-table package is designed for creating ASCII tables in the command line. It provides features like column alignment, table sorting, and custom cell formatting. Compared to cli-columns, easy-table is more suited for creating structured tables with various formatting options.
cli-columns
Columnated lists for the CLI. Unicode and ANSI safe.
$ npm install --save cli-columns
const columns = require('cli-columns');
const chalk = require('chalk');
const values = [
'blue' + chalk.bgBlue('berry'),
'笔菠萝' + chalk.yellow('苹果笔'),
chalk.red('apple'), 'pomegranate',
'durian', chalk.green('star fruit'),
'パイナップル', 'apricot', 'banana',
'pineapple', chalk.bgRed.yellow('orange')
];
console.log(columns(values));
values
{Array<String>}
Array of strings to display.options
{Object}
character
{String}
(default: ' '
) Padding character.newline
{String}
(default: '\n'
) Newline character.padding
{Number}
(default: 2
) Space between columns.sort
{Boolean}
(default: true
) Whether to sort results.width
{Number}
(default: process.stdout.columns
) Max width of list.Sorts and formats a list of values into columns suitable to display in a given width.
Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.
$ npm test
MIT © Shannon Moeller
FAQs
Columnated lists for the CLI.
We found that cli-columns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.